package com.auxgroup.smarthome;

/**
 * Created by kevinchen on 2017/9/5.
 * 睡眠曲线控制协议表 （只限于家用空调）
 * 协议详见A13表
 */
public enum SleepDiyDatapointControlEnum {

    SLEEP_DIY_WIND_SPEED("sleep_diy_wind_speed",3,"设定风速",0,4),
    SLEEP_DIY_TEMPERATURE("sleep_diy_temperature",5,"设定温度",8,32);


    /**
     * 数据点字段名称
     */
    private String name;

    /**
     * 在协议中二进制中所占bit位数
     */
    private int bitCount;
    /**
     * 中文描述
     */
    private String displayName;
    /**
     * 最小值
     */
    private int min;
    /**
     * 最大值
     */
    private int max;

    SleepDiyDatapointControlEnum(String name, int bitCount, String displayName, int min, int max) {
        this.name = name;
        this.bitCount = bitCount;
        this.displayName = displayName;
        this.min = min;
        this.max = max;
    }


    public String getName() {
        return name;
    }

    public int getBitCount() {
        return bitCount;
    }

    public int getMin() {
        return min;
    }

    public int getMax() {
        return max;
    }

    public static SleepDiyDatapointControlEnum getSleepDiyDatapointControlEnum(String datapointAttr){
        if (datapointAttr.contains(SleepDiyDatapointControlEnum.SLEEP_DIY_WIND_SPEED.getName())){
            return SleepDiyDatapointControlEnum.SLEEP_DIY_WIND_SPEED;
        }else if (datapointAttr.contains(SleepDiyDatapointControlEnum.SLEEP_DIY_TEMPERATURE.getName())){
            return SleepDiyDatapointControlEnum.SLEEP_DIY_TEMPERATURE;
        }else {
            throw new IllegalArgumentException("传入的普通控制的控制参数不合法！");
        }
    }



}
